<template>
  <h1>中卫护理信息管理研究院 </h1>
  <f-input v-model:value="result" />
  <f-button @click="getList">刷新</f-button>
  <!-- <pre>{{ result }}</pre> -->
  <pre>{{ resultList }}</pre>
  <!-- <pre>{{ planC }}</pre> -->
</template>

<script setup>
import { onBeforeMount, ref } from 'vue';

const result = ref('');
const resultList = ref([]);

const apiServePlanA = (pageNumber=1) => {
  fetch(`http://zwini.org.cn/nurseinfo-web/knowledgeModule/queryPage?content=&auditStatus=5&validFlag=0&moduleId=1&pageSize=10&pageNumber=${pageNumber}`)
    .then(response => response.json())
    .then(res => {
      const data = res.data;
      console.log(data);
      const list = data.result.map(m => Object.assign({ id: m.id, name: m.name }))
      // result.value = list
      resultList.value.push(...list);
      if(data.hasNextPage){
        // apiServePlanA(data.nextPageNumber);
      }
    })
}

const apiServePlanB = (pageNumber=1) => {
  fetch(`http://zwini.org.cn/nurseinfo-web/knowledgeModule/queryPage?content=&auditStatus=5&validFlag=0&moduleId=2&pageSize=20&pageNumber=${pageNumber}`)
    .then(response => response.json())
    .then(res => {
      const data = res.data;
      const list = data.result;
      // result.value = list
      resultList.value.push(...list);
      if(data.hasNextPage){
        apiServePlanB(data.nextPageNumber);
      }
    })
}

const planC = '1703,1695,1698,1693,1680,1679,1670,1671,1672,1673,1674,1675,1676,1677,1678,1644,1664,1665,1666,1529,1668,1630,1631,1632,1633,1634,1635,1636,1637,1638,1639,1640,1641,1642,1643,1617,1619,1620,1622,1624,1626,1628,1629,1616,1625,1623,1621,1618,1615,1614,1613,1612,1598,1599,1600,1597,1596,1595,1594,1593,1592,1591,1590,1589,1588,1601,1602,1603,1604,1605,1606,1607,1608,1609,1519,1517,1515,1509,1508,1490,1487,1491,1522,1479,1523,1524,1527,1533,1525,1532,1531,1530,1540,1537,1536,1535,1478,1534,1544,1477,1543,1542,1567,1568,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1559,1560,1561,1562,1563,1564,1565,1566,1558,1541,1526,1521,1520,1484,1482,1480,1476,1546,1547,1549,1550,1551,1552,1553,1554,1555,1556,1557,1545,1514,1474,1473,1471,1472,1470,1468,1467,1465,1466,1462,1463,1464,1461,1460,1459,1458,1457,1456,1455,1454,1453,1452,1451,1450,1449,1447,1446'
const apiServePlanC = (id) => new Promise((resolve, reject) => {
  fetch(`/nurseinfo-web/knowledgeModule/queryInfoById?id=${id}`)
    .then(response => response.json())
    .then(res => resolve(res.data))
    .catch(() => reject())
})

// const planDErr = '1548,1443,1442,1381,1423,1243,1244,1247,1249,1250,1254,1257,1259,1262,1263,1264,1285,1286,1287,1288,1290,1196,1051,971,924,835,567'

// const planD = '1699,1700,1702,1701,1696,1687,1685,1684,1683,1682,1681,1669,1667,1646,1647,1648,1649,1650,1651,1652,1653,1654,1655,1656,1657,1658,1659,1660,1661,1662,1663,1645,1611,1610,1587,1586,1585,1584,1548,1443,1444,1442,1369,1372,1373,1374,1375,1376,1377,1378,1379,1380,1381,1382,1383,1384,1385,1386,1387,1388,1389,1390,1391,1392,1393,1394,1395,1396,1397,1398,1399,1400,1401,1402,1403,1404,1405,1406,1407,1408,1409,1410,1411,1412,1413,1414,1415,1416,1417,1418,1419,1420,1421,1422,1423,1424,1425,1426,1427,1428,1429,1430,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1371,1370,1368,1367,1366,1365,1364,1363,1362,1361,1360,1359,1358,1356,1355,1225,1226,1227,1228,1229,1230,1231,1232,1233,1234,1235,1236,1237,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1249,1250,1251,1252,1253,1254,1255,1256,1257,1258,1259,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,1270,1271,1272,1273,1274,1275,1276,1277,1278,1279,1280,1281,1282,1283,1284,1285,1286,1287,1288,1289,1290,1291,1292,1293,1294,1295,1296,1297,1298,1299,1300,1301,1302,1303,1304,1305,1306,1307,1308,1309,1310,1311,1312,1313,1314,1315,1316,1317,1318,1319,1320,1321,1322,1323,1324,1325,1326,1327,1328,1329,1330,1331,1332,1333,1334,1335,1336,1337,1338,1339,1340,1341,1342,1343,1344,1345,1346,1347,1348,1349,1350,1351,1352,1353,1354,1191,1192,1193,1194,1195,1196,1197,1198,1199,1200,1201,1202,1203,1204,1205,1206,1207,1208,1209,1210,1211,1212,1213,1214,1215,1216,1217,1218,1219,1220,1221,1222,1223,1224,1164,1190,1189,1188,1187,1186,1185,1184,1183,1182,1181,1180,1179,1178,1177,1176,1175,1174,1173,1172,1171,1170,1169,1168,1167,1166,1165,1131,1132,1133,1134,1135,1136,1137,1138,1139,1140,1141,1142,1143,1144,1145,1146,1147,1148,1149,1151,1152,1153,1154,1155,1156,1157,1158,1159,1160,1161,1162,1163,1096,1097,1098,1099,1100,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,1117,1118,1119,1120,1121,1122,1123,1124,1125,1126,1127,1128,1129,1130,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1054,1055,1056,1057,1058,954,955,957,958,960,961,962,963,964,965,966,967,968,969,970,1036,1037,1039,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1053,1052,1051,971,972,973,1035,974,975,976,977,978,979,980,1034,981,982,983,984,985,1033,986,987,988,989,990,1032,991,992,993,1031,994,995,996,997,998,1030,999,1029,1000,1001,1002,1003,1004,1028,1005,1006,1007,1008,1009,1011,1012,1013,1014,1015,1016,1017,1018,1019,1020,1021,1022,1025,1026,1023,1024,959,1027,956,1010,942,943,944,945,946,953,947,948,949,950,952,951,688,689,941,690,691,692,693,694,695,696,940,698,699,700,939,701,702,703,704,705,937,938,706,707,708,710,712,713,936,935,714,718,723,724,725,933,934,726,931,932,727,728,930,729,730,731,732,929,733,735,736,928,737,743,927,745,747,926,749,750,752,753,925,755,756,757,924,758,759,923,761,922,762,763,919,920,921,764,765,767,768,918,917,769,771,766,916,915,772,773,774,775,914,776,777,913,778,779,780,912,781,911,782,783,784,785,786,787,788,789,910,790,791,792,793,794,795,909,796,902,903,907,908,904,905,906,901,798,799,900,800,801,802,898,899,803,806,807,897,808,809,896,810,811,895,813,814,815,816,894,818,819,820,821,822,893,823,824,826,827,892,828,830,831,832,891,834,835,886,887,889,890,888,836,884,885,837,839,842,844,845,882,846,848,849,850,852,881,853,880,854,855,856,857,858,879,859,878,861,862,863,864,865,866,867,877,868,869,870,871,872,873,874,875,876,716,860,840,851,847,843,841,833,829,825,817,812,805,770,760,754,751,748,746,744,742,741,740,739,738,734,722,721,720,719,717,715,711,709,697,687,683,661,662,663,664,665,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,684,685,686,617,618,619,620,621,622,623,624,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640,641,642,643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,569,570,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,586,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601,602,603,604,605,606,607,608,609,610,611,612,613,614,615,616,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,544,545,546,547,548,549,550,551,552,553,554,555,557,558,559,560,561,562,563,564,565,566,567,568,526,486,487,488,490,493,494,495,496,497,498,499,508,500,502,503,504,505,506,507,501,491,489,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,411,410,409,408,407,406,405,402,404,403,401,399,400,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,377,378,343,344,345,346,347,349,350,351,352,353,355,327,328,329,331,332,334,336,337,310,311,312,313,314,315,316,317,322,325,283,286,287,288,289,290,291,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,275,276,277,278,279,280,281,273,272'
// const planD = '1699,1700,1702,1701,1696,1687,1685,1684,1683,1682,1681,1669,1667,1646,1647,1648,1649,1650,1651'
// const planD = '1652,1653,1654,1655,1656,1657,1658,1659,1660,1661,1662,1663,1645,1611,1610,1587,1586,1585,1584,1548,1443,1444,1442,1369,1372,1373,1374,1375,1376,1377,1378,1379,1380,1381,1382,1383,1384,1385'
// const planD = '1386,1387,1388,1389,1390,1391,1392,1393,1394,1395,1396,1397,1398,1399,1400,1401,1402,1403,1404,1405,1406,1407,1408,1409,1410,1411,1412,1413,1414,1415,1416,1417,1418,1419,1420,1421,1422,1423'
// const planD = '1424,1425,1426,1427,1428,1429,1430,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1371,1370,1368,1367,1366,1365,1364,1363,1362,1361,1360,1359,1358,1356,1355,1225,1226,1227,1228,1229,1230'
// const planD = '1231,1232,1233,1234,1235,1236,1237,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1249,1250,1251,1252,1253,1254,1255,1256,1257,1258,1259,1260,1261,1262,1263,1264,1265,1266,1267,1268'
// const planD = '1269,1270,1271,1272,1273,1274,1275,1276,1277,1278,1279,1280,1281,1282,1283,1284,1285,1286,1287,1288,1289,1290,1291,1292,1293,1294,1295,1296,1297,1298,1299,1300,1301,1302,1303,1304,1305,1306'
// const planD = '1307,1308,1309,1310,1311,1312,1313,1314,1315,1316,1317,1318,1319,1320,1321,1322,1323,1324,1325'
// const planD = '1326,1327,1328,1329,1330,1331,1332,1333,1334,1335,1336,1337,1338,1339,1340,1341,1342,1343,1344'
// const planD = '1345,1346,1347,1348,1349,1350,1351,1352,1353,1354,1191,1192,1193,1194,1195,1196,1197,1198,1199'
// const planD = '1200,1201,1202,1203,1204,1205,1206,1207,1208,1209,1210,1211,1212,1213,1214,1215,1216,1217,1218'
// const planD = '1219,1220,1221,1222,1223,1224,1164,1190,1189,1188,1187,1186,1185,1184,1183,1182,1181,1180,1179'
// const planD = '1132,1133,1134,1135,1152,1153,1154,1155,1103,1104,1105,1106'
// const planD = '1178,1177,1176,1175,1174,1173,1172,1171,1170,1169,1168,1167,1166,1165,1131'
// const planD = '1136,1137,1138,1139,1140,1141,1142,1143,1144,1145,1146,1147,1148,1149,1151'
// const planD = '1156,1157,1158,1159,1160,1161,1162,1163,1096,1097,1098,1099,1100,1101,1102'
// const planD = '1121,1122,1123,1124,1125,1085,1086,1087,1088,1089,1067,1068,1069,1070,1071'
// const planD = '1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,1117,1118,1119,1120'
// const planD = '1126,1127,1128,1129,1130,1076,1077,1078,1079,1080,1081,1082,1083,1084'
// const planD = '1090,1091,1092,1093,1094,1095,1059,1060,1061,1062,1063,1064,1065,1066'
// const planD = '1072,1073,1074,1075,1054,1055,1056,1057,1058,954,955,957,958,960,961'
// const planD = '969,970,1036,1037,1039,1040,1041,1042,1043,1044,1045,1046,1047,1048'
// const planD = '972,973,1035,974,975,976,977,978,979,980,1034,981,982,983,984,985'
// const planD = '991,992,993,1031,994,995,996,997,998,1030,999,1029,1000,1001,1002,1003'
// const planD = '962,963,964,965,966,967,968,1049,1050,1053,1052,1051,971,1033,986'
// const planD = '1008,1009,1011,1012,1013,1014,1015,1016,1017,1018,1019,1020,1021,1022'
// const planD = '1027,956,1010,942,943,944,945,946,953,947,948,949,950,952,951,688,689,941'
// const planD = '696,940,698,699,700,939,701,702,703,704,705,937,938,706,707,708'
// const planD = '718,723,724,725,933,934,726,931,932,727,728,930,729,730,731,732,929'
// const planD = '1004,1028,1005,1006,1007,987,988,989,990,1032,1025,1026,1023,1024,959'
// const planD = '690,691,692,693,694,695,710,712,713,936,935,714,733,735,736,928,737,743,927'
// const planD = '745,747,926,749,750,752,753,925,755,756,757,924,758,759,923,761'
// const planD = '764,765,767,768,918,917,769,771,766,916,915,772,773,774,775,914'
// const planD = '911,782,783,784,785,786,787,788,789,910,790,791,792,793,794,795'
// const planD = '904,905,906,901,798,799,900,800,801,802,898,899,803,806,807,897'
// const planD = '922,762,763,919,920,921,776,777,913,778,779,780,912,781,909,796'
// const planD = '808,809,896,810,811,895,813,902,903,907,908,830,831,832,891,834,835,886'
// const planD = '814,815,816,894,818,819,820,821,822,893,823,824,826,827,892,828'
// const planD = '887,889,890,888,836,884,885,837,839,842,844,845,882,846,848,849'
// const planD = '856,857,858,879,859,878,861,862,863,864,865,866,867,877,868,869'
// const planD = '716,860,840,851,847,843,841,833,829,825,817,812,805,770,760,754,751'
// const planD = '850,852,881,853,880,854,855,870,871,872,873,874,875,876,748,746'
// const planD = '739,738,734,722,721,720,719,717,715,711,709,697,687,683,661,662'
// const planD = '671,672,673,674,675,676,677,678,679,680,681,682,684,685,686,617'
// const planD = '625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640'
// const planD = '648,649,650,651,652,653,654,655,656,657,658,659,660,569,570,571'
// const planD = '744,742,741,740,663,664,665,667,668,669,670,618,619,620,621,622'
// const planD = '641,642,643,644,645,646,647,572,573,574,575,576,577,578,623,624'
// const planD = '579,580,581,582,583,584,585,586,587,588,589,590,591,592,593,594'
// const planD = '602,603,604,605,606,607,608,609,610,611,612,613,614,615,616,511'
// const planD = '521,522,523,524,525,527,528,529,530,531,532,533,534,535'
// const planD = '544,547,548,549,550,551,552,553,554,555,557,558,559,560'
// const planD = '595,598,599,600,601,512,513,514,515,516,517,518,501,491'
// const planD = '536,539,540,541,542,561,562,563,564,565,566,567,506,507'
// const planD = '568,526,486,487,488,490,493,494,495,496,497,498,499,508'
// const planD = '519,520,545,546,596,597,537,538,500,502,455,456,478,479'
// const planD = '427,428,484,485,347,349,412,404,403,359,360,322,325,275'
// const planD = '489,442,443,444,445,446,447,448,449,450,451,452,453,454'
// const planD = '464,465,466,467,468,469,470,471,472,473,474,475,476,477'
// const planD = '413,414,415,416,417,418,419,420,421,422,423,424,425,426'
// const planD = '503,504,505,457,458,459,460,461,462,463,480,481,482,483'
// const planD = '429,430,431,432,433,434,435,350,351,352,353,355,327,328'
// const planD = '368,369,370,371,372,373,374,375,377,378,343,344,345,346'
// const planD = '436,437,438,439,440,441,411,410,409,408,407,406,405,402'
// const planD = '384,385,386,387,388,389,390,391,392,393,394,395,396,358'
// const planD = '329,331,332,334,336,337,310,311,312,313,314,315,316,317'
// const planD = '294,295,296,297,298,299,300,301,302,303,304,305,306,307,308'
// const planD = '401,399,400,380,381,382,383,361,362,363,364,365,366,367'
// const planD = '283,286,287,288,289,290,291,276,277,278,279,280,281,273,272'
const apiServePlanD = (id) => new Promise((resolve, reject) => {
  fetch(`/nurseinfo-web/knowledgeModule/queryInfoById?id=${id}`)
    .then(response => response.json())
    .then(res => resolve(res.data))
    .catch(() => reject())
})

const getList = () => {
  resultList.value = [];
  // apiServePlanA(1);
  // apiServePlanB(1);
  // planC.split(',').map(m => apiServePlanC(m).then(res => resultList.value.push(res)))
  // planD.split(',').map(m => apiServePlanD(m).then(res => resultList.value.push(res)))
  result.value.split(',').map(m => apiServePlanD(m).then(res => resultList.value.push(res)))
}

onBeforeMount(() => {
  // apiServe();
});
</script>

<style lang="scss">

</style>
